package com.twu.biblioteca;

/**
 * Created with IntelliJ IDEA.
 * User: Shreyansh
 * Date: 22/8/13
 * Time: 10:42 PM
 * To change this template use File | Settings | File Templates.
 */
public class BookManager {
    public void reserveBook(String bookToReserve) {
        BookList listOfBooks= new BookList();
        int isBookPresent=0;
        int indexOfBook=0;
        for(Book book:listOfBooks.getBookList())
        {
            if(book.bookname.equals(bookToReserve))
            {

                isBookPresent=1;
                if (listOfBooks.quantityOfBook[indexOfBook]!=0)
                {
                    listOfBooks.quantityOfBook[indexOfBook]--;
                    System.out.println("Book reserved successfully");
                    break;
                }
                else
                {
                    System.out.println("Sorry Book not available");
                    break;
                }
            }
            indexOfBook++;
        }
        if(isBookPresent==0)

            System.out.println("Sorry we do not have this Book");
    }
}
